package com.lty.springmvc.interceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

public class ThirdInterceptor implements HandlerInterceptor {

	/***
	 * 本方法在渲染视图之后被调用
	 * 
	 * 运用场景：释放资源
	 */
	@Override
	public void afterCompletion(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, Exception arg3)
			throws Exception {
		System.out.println("[ThirdInterceptor] afterCompletion");
	}

	/***
	 * 本方法在调用目标方法之后，但渲染视图之前调用
	 * 
	 * 运用场景：可以对请求域中的属性和视图进行修改
	 */
	@Override
	public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView)
			throws Exception {
		System.out.println("[ThirdInterceptor] postHandle");
	}

	/***
	 * 该方法在目标方法调用之前被调用
	 * 若返回false，将不会继续调用后续的拦截器和目标方法，否则将继续。
	 * 
	 * 运用场景：权限、日志、事务
	 */
	@Override
	public boolean preHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2) throws Exception {
		System.out.println("[ThirdInterceptor] preHandle");
		return true;
	}

}
